// alert(1688);

var cans = alicans();
var pageUrl = window.location.href;
$.ajax({
    url: "http://193.112.113.247:8801/?c=ctrl_ali_product&a=getOfferId",
    type: "POST",
    data: {pageUrl : pageUrl, cans : cans},
    success: function (result) {
        // result = JSON.parse(result);
        // alert(result.info);
    }
});
//三秒后关闭窗口
setTimeout(function(){window.opener = null;window.close();},3000);

function alicans() {
    var canvas = document.createElement('canvas');
    var ctx = canvas.getContext('2d');
    var txt = 'http://security.tencent.com/';
    ctx.textBaseline = "top";
    ctx.font = "14px 'Arial'";
    ctx.textBaseline = "tencent";
    ctx.fillStyle = "#f60";
    ctx.fillRect(125, 1, 62, 20);
    ctx.fillStyle = "#069";
    ctx.fillText(txt, 2, 15);
    ctx.fillStyle = "rgba(102, 204, 0, 0.7)";
    ctx.fillText(txt, 4, 17);

    var b64 = canvas.toDataURL().replace("data:image/png;base64,", "");
    var bin = atob(b64);
    var crc = bin2hexs(bin.slice(-16, -12));
    //var crc = bin.slice(-16,-12);
    return crc;
}

function bin2hexs(str) {
    var result = "";
    for (i = 0; i < str.length; i++) {
        result += int16_to_hexs(str.charCodeAt(i));
    }
    return result;
}

function int16_to_hexs(i) {
    var result = i.toString(16);
    var j = 0;
    while (j + result.length < 4) {
        result = "0" + result;
        j++;
    }
    return result;
}